<?php
class Cip_statistics_m extends MY_Model {
	public function getAllStatistics($limit){
		return $this->cip_statistics_m->select('cip_statistics.id, cip_statistics.match, cip_statistics.linked, cip_statistics.date, g.title, g.url')
		//->from('cip_samples s')
		->join('cip_groups g','cip_statistics.group_id = g.id')
		->where('g.valid', 1)
		->order_by("cip_statistics.date","DESC")
		->limit($limit)
		->get_all();
	}
	public function countAllStatistics(){
		return $this->cip_statistics_m->select('cip_statistics.id, cip_statistics.match, cip_statistics.linked, cip_statistics.date, g.title, g.url')
		//->from('cip_samples s')
		->join('cip_groups g','cip_statistics.group_id = g.id')
		->where('g.valid', 1)
		->order_by("cip_statistics.date","DESC")
		->get_all();
	}
	public function insert($input = array())
	{
		$id = parent::insert(array(
				'group_id'=>$input['groupId'],
				'match'=>$input['match'],
				'linked'=>$input['linked'],
				'date'=>$input['date']
		));
	
		return $id;
	}
	public function updateMatch($id, $input)
	{
		return parent::update($id, array(
			'match'=> $input['match']
		));
	}
	public function updateLinked($id, $input)
	{
		return parent::update($id, array(
				'linked'=> $input['linked']
		));
	}
}
?>